//reverse an unsigned integer
//e.g 2015 to 5102
//e.g 100 to 1
//e.g 0  to 0
//there is a bug!!!overflow
//2000000009
//solved by test if(m = reverse_int(reverse_int(m)))

#include <iostream>
#include <cstdlib>
#include <stdexcept>
using namespace std;

//for-loop
unsigned int reverse_int(unsigned int n)
{
  unsigned int m;
  for(m = 0;n!=0;n/=10)

    m = m * 10 + n % 10;
  return m;
}

int main(int argc, char *argv[])
{
  int m;
  if (argc == 2)
    m = atoi(argv[1]);
  else
    m = 1212;
  int r_m;
  try {
     r_m = reverse_int(m);
     if((unsigned)m != reverse_int(r_m) ){
       cout<<"..."<<endl;
       throw overflow_error("the integer is too large\n");
     }
  }
  catch(exception& e){
    cout<<e.what()<<endl;
    return 1;
  }
  cout<<r_m<<endl;
  return 0;
}
